package active;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author 陈华旺
 * @version 1.0
 * @date 2023年11月23日 15:05
 * @Description TODO
 */
@WebServlet("/test17")
public class Test17SessionGet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        Double num = (Double) session.getAttribute("num");

        resp.setContentType("text/html;charset=utf8");

        resp.getWriter().println( "num:"+session.getAttribute("num") );

        if(num==null){
            resp.getWriter().println("未登录，请先登录");
        }else{
            resp.getWriter().println( "已登录" );
        }
    }
}
